#!/bin/sh
# Copyright (c) 2010, bkil.hu
# This program is free software and can be distributed under the terms of
# the GNU General Public License v2,
# see COPYING for detailed licensing terms.

# created on 2010-08-06 21:42
# need for manual edit: tidying, upper case all initials of channel names

# pdftotext ~/Downloads/budapest_100701.pdf
IN=tv.lst
I=1
cat <<CAT
<?xml version="1.0"?>
<!DOCTYPE stationlist PUBLIC "-//tvtime//DTD stationlist 1.0//EN" "http://tvtime.sourceforge.net/DTD/stationlist1.dtd">
<stationlist xmlns="http://tvtime.sourceforge.net/DTD/">
  <list norm="PAL" frequencies="europe" audio="bg">
CAT
cat $IN |
while read R
do
 F=`echo "$R"|
    sed -r 's~^[^ ]* [^ ]* ([^ ]*) MHz.*$~\1~
            s~,~.~'`
 D=`echo "$R"|
    sed -r 's~^[^ ]* [^ ]* [^ ]* MHz (.*)\<(dual|nicam|mono|stereo)\>.*$~\1~
            s~ [a-z].*$~~
            s~\**$~~'`
 echo "    <station name=\"$D\" active=\"1\" position=\"$I\" band=\"Custom\" channel=\"${F}MHz\" finetune=\"0\" norm=\"PAL\" audio=\"bg\"/>"
 I=`expr $I + 1`
done
cat <<CAT
  </list>
</stationlist>
CAT

